<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        let a = Math.round(Math.random() * (10 - 1 + 1) + 1);
        let num = +prompt("请输入一个数字");
        while (num != a) {
            if (num > a) {
                alert("大于数字");
                num = +prompt("请输入一个数字");
            } else {
                alert("小于数字");
                num = +prompt("请输入一个数字");
            }
        }
        alert("正确！");
    </script>
</body>

</html>